package com.talkweb.securitycamera.data.hadoopFile;

import com.talkweb.securitycamera.common.constans.FileType;
import ohos.app.Context;

import java.io.File;

/**
 * 提供媒体存储目录的工具类
 *
 * @author : frank
 * @date : 2021/2/2 10:07
 */
class MediaDirectoryProvider {

    private static final String VIDEO_DIR = "video";
    private static final String IMAGE_DIR = "image";

    /**
     * @noinspection ResultOfMethodCallIgnored
     */
    static File provideMediaDirectory(Context context, FileType fileType) {
        File distDir = context.getDistributedDir();
        System.out.println("分布式文件夹："+distDir);
        String dir = fileType == FileType.FILE_TYPE_VIDEO ? VIDEO_DIR : IMAGE_DIR;
        File mediaDirectory = new File(distDir.getAbsolutePath() + File.separator + dir);
        if (!mediaDirectory.exists()) {
            mediaDirectory.mkdirs();
        }
        return mediaDirectory;
    }

}
